package com.example;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;
/*import sun.tools.java.Environment;*/
import org.springframework.core.env.Environment;

import java.util.Objects;

@SpringBootApplication
public class Homework2Application {

    public static void main(String[] args) {
        ConfigurableApplicationContext context = SpringApplication.run(Homework2Application.class, args);
        Environment environment = context.getEnvironment();
        String host = "localhost";
        int port = Integer.parseInt(Objects.requireNonNull(environment.getProperty("server.port")));
        String rootPath = environment.getProperty("server.servlet.context-path", "/");
        String url = String.format("访问根路径的地址信息: http://%s:%d%s", host, port, rootPath);
        System.out.println(url);
        /*SpringApplication.run(Homework2Application.class, args);
        Environment environment = context.getEnvironment();
        String host = "localhost";
        int port = Integer.parseInt(Objects.requireNonNull(environment.getProperty("server.port")));
        String rootPath = environment.getProperty("server.servlet.context-path", "/");
        String url = String.format("访问根路径的地址信息: http://%s:%d%s", host, port, rootPath);
        System.out.println(url);*/
    }

}
